package cn.yunhe.control;

import cn.yunhe.entity.Point;
import com.alibaba.fastjson.JSON;

public class CalculatorAction extends ActionBase {
    private double num1;
    private double num2;
    private double result;
    private Point point;
    private String res;

    @Override
    public String execute() throws Exception {

        int x = point.getX();
        int y = point.getY();
        Point point1 = new Point(x,y);
        setRes(JSON.toJSONString(point1));
        return SUCCESS;
    }

    public String add() {
        double resul = num1 + num2;
        setResult(resul);
        return SUCCESS;
    }

    public String sub() {
        double resul = num1 - num2;
        setResult(resul);
        return SUCCESS;
    }

    public String muti() {
        double resul = num1 * num2;
        setResult(resul);
        return SUCCESS;
    }

    public String div() {
        double resul = num1 / num2;
        setResult(resul);
        return SUCCESS;
    }

    public double getNum1() {
        return num1;
    }

    public void setNum1(double num1) {
        this.num1 = num1;
    }

    public double getNum2() {
        return num2;
    }

    public void setNum2(double num2) {
        this.num2 = num2;
    }


    public double getResult() {
        return result;
    }

    public void setResult(double result) {
        this.result = result;
    }

    public Point getPoint() {
        return point;
    }

    public void setPoint(Point point) {
        this.point = point;
    }

    public String getRes() {
        return res;
    }

    public void setRes(String res) {
        this.res = res;
    }
}
